package com.citsin.atlas.bean

import android.os.Parcel
import android.os.Parcelable

/**
 * citsin
 * 2019-06-03
 */
data class Media(
    val id: String,
    val displayName: String,
    val mediaType: Int,
    val uri: String
) : Parcelable {
    constructor(source: Parcel) : this(
        source.readString(),
        source.readString(),
        source.readInt(),
        source.readString()
    )

    override fun describeContents() = 0

    override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
        writeString(id)
        writeString(displayName)
        writeInt(mediaType)
        writeString(uri)
    }

    companion object {
        @JvmField
        val CREATOR: Parcelable.Creator<Media> = object : Parcelable.Creator<Media> {
            override fun createFromParcel(source: Parcel): Media = Media(source)
            override fun newArray(size: Int): Array<Media?> = arrayOfNulls(size)
        }
    }
}
